package com.yds.common.util;

import org.apache.commons.lang.StringUtils;
import org.jboss.netty.handler.codec.base64.Base64;


/**
 * Created by hansen on 2017/7/11.
 */
public class Test {

    public static void main(String[] args) {


        byte[] text ="test".getBytes(); //待加/解密的数据

//密钥数据
//        byte[] keyData = Base64.decode("Uqt3frmnmVQQgU7S4wUJnKBrQ0CypPii");
//        String algorithm = “DESede”; //算法名称
//        String fullAlg = algorithm + “/CBC/PKCS5Padding”;
//
//        Cipher cipher1 = Cipher.getInstance(fullAlg);
//        int blockSize = cipher1.getBlockSize();
//        byte[] iv = new byte[blockSize];
//        for (int I = 0; I < blockSize; ++i) {
//            iv[i] = 0;
//        }
//        Cipher cipher = Cipher.getInstance(fullAlg);
//        SecretKey secretKey = new SecretKeySpec(keyData, StringUtils.substringBefore(fullAlg, “/”));
//        IvParameterSpec ivSpec = new IvParameterSpec(iv);
///**加密*/
//        cipher.init(Cipher.ENCRYPT_MODE, secretKey, ivSpec);
//        byte[] cipherBytes = cipher.doFinal(text);
//        String cipherString = Base64.encode(cipherBytes);
//
///**解密*/
//        cipher.init(Cipher.DECRYPT_MODE, secretKey, ivSpec);
//        byte[] resultBytes = cipher.doFinal(Base64.decode(cipherString));
    }
}
